<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>1.匹配正整数</h2>
    <pre>
        // 匹配正整数
        let isPositiveNum = val => {
            return /^[1-9]d*$/.test(val);
        };
    </pre>
    <br/>
    <h2>2.匹配负整数</h2>
    <pre>
        // 匹配负整数
        let isNegativeNum = val => {
            return /^-[1-9]d*$/.test(val);
        };
    </pre>
    <br/>
    <h2>3.匹配整数</h2>
    <pre>
        // 匹配整数
        let isInteger = val => {
            return /^(-|\+)?\d+$/.test(val);
        };
    </pre>
</body>
</html>